package edu.sctu.wujiayi.month05.day20150524;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by user11 on 2015/5/24.
 */
public class One extends More {
    public List<Teacher> getTeacherInfor(){
        Teachers teachers = new Teachers();

        List<Teacher> list = teachers.getList();

        for (int i = 0;i<list.size()-1;i++){

            for(int j = 0;j<list.size();j++){
                if(list.get(j).number>list.get(j+1).number){
                    list.add(j,list.get(j+1));
                    list.remove(list.get(j+2));

                }
            }
        }
        System.out.println(list);
        return list;
    }

    public List<Student> getStudent(int code,List<Student> list){
        Teachers teachers = new Teachers();
        List<Teacher> list1 = teachers.getList();
        List<Student> lists = new ArrayList<>();
        for(int i = 0;i<list1.size();i++){
            for(int j = 0;j<list1.get(i).student.size();j++){
                lists.add(list1.get(i).student.get(j));

            }

        }

        for(int i = 0;i<lists.size()-1;i++){
            for (int j = 0;j<lists.size()-1;j++){
                if(lists.get(j).grade>lists.get(j+1).grade){
                    lists.add(j,lists.get(j+1));
                    lists.remove(lists.get(j+2));

                }
            }
        }
        for (int i = 0;i<lists.size();i++){

            if (lists.get(i).grade>code){
                System.out.println(lists.get(i));
            }
        }
        //System.out.println(lists);
        return lists;
    }
    InterfaceOne inter = new InterfaceOne() {
        @Override
        public void method(List<Student> list) {
            getStudent(60,list);
        }
    };
    public void getCode(){
       // Teachers teachers = new Teachers();
        List<Teacher> list;
        list = printTitol();
        List<Student> students = new ArrayList<>();
        for (int i = 0;i<list.size();i++){
            for (int j = 0;j<list.size();j++){

                    System.out.println(list.get(i).getStudent().get(0).getName());

//                   students.add(list.get(i).getStudent().get(j));

            }

        }
        inter.method(students);
    }

}
